package com.ymatou.iapi.godmch.testcase;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.agentproducts.parameter.AddAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.ImportAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.ProductListDto;
import com.ymatou.iapi.godmch.parameter.CreateCodeBean;
import com.ymatou.iapi.godmch.parameter.SetMarkupConfigBean;
import com.ymatou.iapi.godmch.parameter.createmchBean;
import com.ymatou.iapi.godmch.service.CreateCodeCall;
import com.ymatou.iapi.godmch.service.SetMarkupConfigCall;
import com.ymatou.mq.admin.parameter.MessageListBean;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.AddAgentProductCallService;
import com.ymttest.business.service.MqQueryCallService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.database.mapping.godmch.MarkupConfigMapper;
import com.ymttest.database.model.MarkupConfig;
import com.ymttest.database.model.godmch.interactionstate;
import com.ymttest.database.sqlwapper.godmch.MarkupconfigWapper;
import com.ymttest.utils.TestDataManager;

import sun.util.logging.resources.logging;

/**
 * 设置自动加价规则Test FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_SetMarkupConfig {
	private static SetMarkupConfigBean bean;
	private static SetMarkupConfigCall call;
	private MqQueryCallService mqQueryCallService=new MqQueryCallService();

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("设置自动加价规则Test");
	}

	@Before
	public void caseUp() {
		bean = new SetMarkupConfigBean();
		call = new SetMarkupConfigCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	private void  check_verify() throws InterruptedException {
		Logger.verifyEquals("200", call.getString("status"), "验证code");
		for(int i=0;i<bean.getSupplierId().size();i++){
			MarkupConfig markupConfig = new MarkupconfigWapper().selectbyPrimaryKey(bean.getAgentId(), bean.getSupplierId().get(i)).get(0);
			Logger.verifyEquals(markupConfig.getMarkupType(), bean.getMarkupType(), "验证markupType");

			//当不加价时，percentage、decimalType 都为0
			Logger.verifyEquals(markupConfig.getPercentage().stripTrailingZeros().toPlainString(),bean.getMarkupType()==1?bean.getPercentage().stripTrailingZeros().toPlainString():"0", "验证percentage");
			Logger.verifyEquals(markupConfig.getDecimalType(),bean.getMarkupType()==1?bean.getDecimalType():0, "验证decimalType");
			
			Logger.verifyEquals(markupConfig.getOnSaleType(),bean.getOnSaleType(), "验证onSaleType");
			Logger.verifyEquals(markupConfig.getRefreshProduct(), bean.getRefreshProduct(), "验证refreshProduct");
			Logger.verifyEquals(markupConfig.getConfigStatus(), 0, "验证configStatus");
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_setMarkupConfig_001() {
		Logger.start(true,"设置自动加价规则-供货商未设置(新增)-成功");
		try {
			bean=GodmchManageCallService.initSetMarkupConfigV2(null, null);
			call.setData(bean);
			call.callService();			
			Logger.comment("mchId_channl:"+bean.getSupplierId().get(0));
			Logger.comment("agentId:"+bean.getAgentId());
			check_verify();
			//验证发消息总线-新增
	        MessageListBean messageListBean=mqQueryCallService.initGodmchManage(String.valueOf(bean.getAgentId()), "set_markupconfig");
	        List <Map> mq=mqQueryCallService.GetMqMessage(messageListBean);
	        if(mq.size()==0){
				Thread.sleep(5000);
				mq = MqQueryCallService.GetMqMessage(messageListBean);
			}
	        Logger.verifyEquals(bean.getAgentId(),mq.get(0).get("agentId"), "验证消息总线代理Id AgentId");
	        Logger.verifyEquals(bean.getSupplierId().get(0),mq.get(0).get("supplierId"), "验证消息总线服务商 SupplierId");
	        Logger.verifyEquals(1,mq.get(0).get("operateType"), "验证消息总线operateType=1新增自动加价");
	        
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_setMarkupConfig_017() {
		Logger.start(true,"设置自动加价规则-供货商已设置(修改)-成功");
		try {
			List<Integer> supplierIds=new ArrayList<>();
			supplierIds.add(500777072);
			bean=GodmchManageCallService.initSetMarkupConfigV2(500777071, supplierIds);
			bean.setMarkupType(1);
			bean.setPercentage(new BigDecimal(TestDataManager.getRandomIntNum(2)));
			bean.setRefreshProduct(true);
			
			call.setData(bean);
			call.callService();				
			Logger.comment("mchId_channl:"+bean.getSupplierId().get(0));
			Logger.comment("agentId:"+bean.getAgentId());
			check_verify();			
			
			//验证发消息总线-修改
	        MessageListBean messageListBean=mqQueryCallService.initGodmchManage(String.valueOf(bean.getAgentId()), "set_markupconfig");
	        List <Map> mq=mqQueryCallService.GetMqMessage(messageListBean);
	        if(mq.size()==0){
				Thread.sleep(5000);
				mq = MqQueryCallService.GetMqMessage(messageListBean);
			}
	        Logger.verifyEquals(bean.getAgentId(),mq.get(0).get("agentId"), "验证消息总线代理Id AgentId");
	        Logger.verifyEquals(bean.getSupplierId().get(0),mq.get(0).get("supplierId"), "验证消息总线服务商 SupplierId");
	        Logger.verifyEquals(2,mq.get(0).get("operateType"), "验证消息总线operateType=2修改自动加价");
	        
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_setMarkupConfig_002() {
		Logger.start(true,"设置自动加价规则-2个供货商-成功");
		try {
			bean=GodmchManageCallService.initSetMarkupConfigV2(null, null);
			Integer mchId_channl1=bean.getSupplierId().get(0);
			Integer agentId=bean.getAgentId();
			
			// 创建供货商2邀请码
			CreateCodeBean createAllMsgSellerMch = GodmchManageCallService.CreateAllMsgSellerMch();
			CreateCodeCall createCodeCall2 = GodmchManageCallService.createCodeCall(createAllMsgSellerMch);
			Integer mchId_channl2= createAllMsgSellerMch.getMchId();
			//绑定
			GodmchManageCallService.InitbindmchBean(agentId, createCodeCall2.getCode());
			
			List<Integer> supplierIds=new ArrayList<Integer>();
			supplierIds.add(mchId_channl1);
			supplierIds.add(mchId_channl2);
			bean.setSupplierId(supplierIds);
			call.setData(bean);
			call.callService();			
			Logger.comment("mchId_channl1:"+mchId_channl1);
			Logger.comment("mchId_channl2:"+mchId_channl2);
			Logger.comment("agentId:"+bean.getAgentId());
			
			check_verify();		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_setMarkupConfig_003() {
		Logger.start(true,"设置自动加价规则-加价类型1按百分比加价-成功");
		try {
			bean=GodmchManageCallService.initSetMarkupConfigV2(null, null);
			bean.setMarkupType(1);
			call.setData(bean);
			call.callService();			
			Logger.comment("mchId_channl:"+bean.getSupplierId().get(0));
			Logger.comment("agentId:"+bean.getAgentId());
			check_verify();	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_setMarkupConfig_004() {
		Logger.start(true,"设置自动加价规则-加价类型2建议零售价-成功");
		try {
			bean=GodmchManageCallService.initSetMarkupConfigV2(null, null);
			bean.setMarkupType(2);
			call.setData(bean);
			call.callService();			
			Logger.comment("mchId_channl:"+bean.getSupplierId().get(0));
			Logger.comment("agentId:"+bean.getAgentId());
			check_verify();			
			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_setMarkupConfig_005() {
		Logger.start(true,"设置自动加价规则-加价类型3不加价-成功");
		try {
			bean=GodmchManageCallService.initSetMarkupConfigV2(null, null);
			bean.setMarkupType(3);
			call.setData(bean);
			call.callService();			
			Logger.comment("mchId_channl:"+bean.getSupplierId().get(0));
			Logger.comment("agentId:"+bean.getAgentId());
			check_verify();			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_setMarkupConfig_006() {
		Logger.start(true,"设置自动加价规则-加价类型4不存在-失败");
		try {
			bean=GodmchManageCallService.initSetMarkupConfigV2(null, null);
			bean.setMarkupType(4);
			call.setData(bean);
			call.callService();			
			Logger.verifyEquals("4001", call.getString("status"), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_setMarkupConfig_008() {
		Logger.start(true,"设置自动加价规则-自动加价百分比0.1小于1(加价为大于1的整数)-失败");
		try {
			bean=GodmchManageCallService.initSetMarkupConfigV2(null, null);
			bean.setMarkupType(1);
			bean.setPercentage(new BigDecimal(0.1));
			
			call.setData(bean);
			call.callService();				
			
			Logger.verifyEquals("4001", call.getString("status"), "验证code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_setMarkupConfig_008_1() {
		Logger.start(true,"设置自动加价规则-验证无小数,不支持小数-自动加价百分比1.1-失败");
		try {
			bean=GodmchManageCallService.initSetMarkupConfigV2(null, null);
			bean.setMarkupType(1);
			bean.setPercentage(new BigDecimal(1.1));
			
			call.setData(bean);
			call.callService();				
			
			Logger.verifyEquals("4001", call.getString("status"), "验证code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_setMarkupConfig_009() {
		Logger.start(true,"设置自动加价规则-加价后小数点类型1精确到个位数-成功");
		try {
			bean=GodmchManageCallService.initSetMarkupConfigV2(null, null);
			bean.setMarkupType(1);
			bean.setDecimalType(1);
			
			call.setData(bean);
			call.callService();				
			
			check_verify();				
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_setMarkupConfig_010() {
		Logger.start(true,"设置自动加价规则-加价后小数点类型2保留小数点后1位-成功");
		try {
			bean=GodmchManageCallService.initSetMarkupConfigV2(null, null);
			bean.setMarkupType(1);
			bean.setDecimalType(2);
			
			call.setData(bean);
			call.callService();				
			
			check_verify();			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_setMarkupConfig_011() {
		Logger.start(true,"设置自动加价规则-加价后小数点类型3保留小数点后2位-成功");
		try {
			
			bean=GodmchManageCallService.initSetMarkupConfigV2(null, null);
			bean.setMarkupType(1);
			bean.setDecimalType(3);
			
			call.setData(bean);
			call.callService();				
			
			check_verify();			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_setMarkupConfig_012() {
		Logger.start(true,"设置自动加价规则-加价后小数点类型4精确到十位数-成功");
		try {
			bean=GodmchManageCallService.initSetMarkupConfigV2(null, null);
			bean.setMarkupType(1);
			bean.setDecimalType(4);
			
			call.setData(bean);
			call.callService();				
			
			check_verify();			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_setMarkupConfig_013() {
		Logger.start(true,"设置自动加价规则-上架类型1自动添加到我的店-成功");
		try {
			
			bean=GodmchManageCallService.initSetMarkupConfigV2(null, null);
			bean.setMarkupType(1);
			bean.setOnSaleType(1);
			
			call.setData(bean);
			call.callService();				
			
			check_verify();			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_setMarkupConfig_014() {
		Logger.start(true,"设置自动加价规则-上架类型2手动上架到我的店-成功");
		try {
			bean=GodmchManageCallService.initSetMarkupConfigV2(null, null);
			bean.setMarkupType(1);
			bean.setOnSaleType(2);
			
			call.setData(bean);
			call.callService();				
			
			check_verify();		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_setMarkupConfig_015() {
		Logger.start(true,"设置自动加价规则-覆盖已添加的商品价格-成功");
		try {
			bean=GodmchManageCallService.initSetMarkupConfigV2(null, null);
			bean.setMarkupType(1);
			bean.setRefreshProduct(true);
			
			call.setData(bean);
			call.callService();				
			
			check_verify();			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_setMarkupConfig_016() {
		Logger.start(true,"设置自动加价规则-不覆盖已添加的商品价格-成功");
		try {
			bean=GodmchManageCallService.initSetMarkupConfigV2(null, null);
			bean.setMarkupType(1);
			bean.setRefreshProduct(false);
			
			call.setData(bean);
			call.callService();				
			
			check_verify();				
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_setMarkupConfig_018() {
		Logger.start(true,"设置自动加价规则-代理商id为空-失败");
		try {
			Integer mchId_channl = GodmchManageCallService.CreateSellerMch();
			List<createmchBean> createmchList=GodmchManageCallService.InitcreatemchBeanForAgent(mchId_channl);
			GodmchManageCallService.createmchCallForAgent(createmchList.toArray(new
					createmchBean[createmchList.size()]));

			Integer agentId=createmchList.get(0).getMchId();
			List<Integer> supplierIds=new ArrayList();
			supplierIds.add(mchId_channl);
			
			//bean.setAgentId(null);
			bean.setSupplierId(supplierIds);
			bean.setMarkupType(1);//加价类型1按比例加价2建议零售价3不加价
			bean.setOnSaleType(1);//上架类型1自动添加到我的店2手动上架到我的店
			bean.setPercentage(new BigDecimal(10));//自动加价百分比,无小数
			bean.setDecimalType(1);//加价后小数点类型1,精确到个位数2,保留小数点后1位3,保留小数点后2,位4精确到十位数
			
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("4001", call.getString("status"), "验证code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_setMarkupConfig_019() {
		Logger.start(true,"设置自动加价规则-供货商列表为空-失败");
		try {
			Integer mchId_channl = GodmchManageCallService.CreateSellerMch();
			List<createmchBean> createmchList=GodmchManageCallService.InitcreatemchBeanForAgent(mchId_channl);
			GodmchManageCallService.createmchCallForAgent(createmchList.toArray(new
					createmchBean[createmchList.size()]));

			Integer agentId=createmchList.get(0).getMchId();
			List<Integer> supplierIds=new ArrayList();
			supplierIds.add(mchId_channl);
			
		    bean.setAgentId(agentId);
			//bean.setSupplierId(supplierIds);
			bean.setMarkupType(1);//加价类型1按比例加价2建议零售价3不加价
			bean.setOnSaleType(1);//上架类型1自动添加到我的店2手动上架到我的店
			bean.setPercentage(new BigDecimal(10));//自动加价百分比,无小数
			bean.setDecimalType(1);//加价后小数点类型1,精确到个位数2,保留小数点后1位3,保留小数点后2,位4精确到十位数
			
			call.setData(bean);
			call.callService();			
			Logger.verifyEquals("4001", call.getString("status"), "验证code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_setMarkupConfig_020() {
		Logger.start(true,"设置自动加价规则-加价类型为空-成功");
		try {
			Integer mchId_channl = GodmchManageCallService.CreateSellerMch();
			List<createmchBean> createmchList=GodmchManageCallService.InitcreatemchBeanForAgent(mchId_channl);
			GodmchManageCallService.createmchCallForAgent(createmchList.toArray(new
					createmchBean[createmchList.size()]));

			Integer agentId=createmchList.get(0).getMchId();
			List<Integer> supplierIds=new ArrayList();
			supplierIds.add(mchId_channl);
			
		    bean.setAgentId(agentId);
			bean.setSupplierId(supplierIds);
		//	bean.setMarkupType(1);//加价类型1按比例加价2建议零售价3不加价
			bean.setOnSaleType(1);//上架类型1自动添加到我的店2手动上架到我的店
			bean.setPercentage(new BigDecimal(10));//自动加价百分比,无小数
			bean.setDecimalType(1);//加价后小数点类型1,精确到个位数2,保留小数点后1位3,保留小数点后2,位4精确到十位数
			
			call.setData(bean);
			call.callService();			
			Logger.verifyEquals("4001", call.getString("status"), "验证code");		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_setMarkupConfig_021() {
		Logger.start(true,"设置自动加价规则-供货商的加价规则同步未完成,再重新设置-失败(该供货商的加价规则正在同步中,请稍后再试)");
		try {
			bean=GodmchManageCallService.initSetMarkupConfigV2(null, null);
			call.setData(bean);
			call.callService();		
			call.callService();			
			Logger.verifyEquals("5000", call.getString("status"), "验证code");	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_setMarkupConfig_023() {
		Logger.start(true,"设置自动加价规则-值无改变-不发送mq");
		try {
			Integer mchId_channl = GodmchManageCallService.CreateSellerMch();
			List<createmchBean> createmchList=GodmchManageCallService.InitcreatemchBeanForAgent(mchId_channl);
			GodmchManageCallService.createmchCallForAgent(createmchList.toArray(new
					createmchBean[createmchList.size()]));

			Integer agentId=createmchList.get(0).getMchId();
			List<Integer> supplierIds=new ArrayList();
			supplierIds.add(mchId_channl);
			
		    bean.setAgentId(agentId);
			bean.setSupplierId(supplierIds);
			bean.setMarkupType(3);//加价类型1按比例加价2建议零售价3不加价
			bean.setOnSaleType(1);//上架类型1自动添加到我的店2手动上架到我的店
			//bean.setPercentage(new BigDecimal(10));//自动加价百分比,无小数
			//bean.setDecimalType(1);//加价后小数点类型1,精确到个位数2,保留小数点后1位3,保留小数点后2,位4精确到十位数
			
			call.setData(bean);
			call.callService();		
			
			check_verify();
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_setMarkupConfig_024() {
		Logger.start(true,"设置自动加价规则-值无改变-不发送mq");
		try {
			List<Integer> supplierIds=new ArrayList();
			supplierIds.add(500777210);
			bean=GodmchManageCallService.initSetMarkupConfigV2(500777211, supplierIds);
		
			call.setData(bean);
			call.callService();		
			
			check_verify();
			
		} catch (Exception e) {
			Logger.fail(e);
		}			
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_setMarkupConfig_024_1() {
		Logger.start(true,"设置自动加价规则-删除再添加");
		try {
			//新增
			//删除
			List<Integer> supplierIds=new ArrayList();
			supplierIds.add(500781646);
			bean=GodmchManageCallService.initSetMarkupConfigV2(500781647, supplierIds);
		
			call.setData(bean);
			call.callService();		
			
			check_verify();
			
		} catch (Exception e) {
			Logger.fail(e);
		}			
	}
	
//	@Test
//	@Category({ P1.class })
//	@TestCase
//	public void Tc_SetMarkupConfig_001() {
//		Logger.start(true, "创建一个代理规格，验证数据库");
//		try {
//
//			bean=GodmchManageCallService.initSetMarkupConfigV2(null, null);
//			bean.setPercentage(new BigDecimal(33.0));
//			call=GodmchManageCallService.SetMarketupBeanCall(bean);
//			check_verify();
//
//			
//		} catch (Exception e) {
//			Logger.fail(e);
//		}
//	}
//
//	@Test
//	@Category({ P1.class })
//	@TestCase
//	public void Tc_SetMarkupConfig_002() {
//		Logger.start(true, "按比例加价百分之20，精确个位数，而且自动上架到我的店铺");
//		try {
//			int rootUserId = 500772470;
//			int agentUserId = 500772471;
//			// 验证配置
//			MarkupConfig markupConfig = new MarkupconfigWapper().selectbyPrimaryKey(agentUserId, rootUserId).get(0);
//			Logger.verifyEquals(markupConfig.getMarkupType(), 1, "验证markupType");
//			Logger.verifyEquals(markupConfig.getPercentage().intValue(), 20, "验证percentage");
//			Logger.verifyEquals(markupConfig.getDecimalType(), 1, "验证decimalType");
//			Logger.verifyEquals(markupConfig.getOnSaleType(), 1, "验证onSaleType");
//			Logger.verifyEquals(markupConfig.getRefreshProduct(), true, "验证refreshProduct");
//			Logger.verifyEquals(markupConfig.getConfigStatus(), 0, "验证configStatus");
//
//
//		} catch (Exception e) {
//			Logger.fail(e);
//		}
//	}
//
//	@Test
//	@Category({ P1.class })
//	@TestCase
//	public void Tc_SetMarkupConfig_003() {
//		Logger.start(true, "按比例加价百分之33，精确后一位，而且自动上架到我的店铺");
//		try {
//			int rootUserId = 500772483;
//			int agentUserId = 500772484;
//			// 验证配置未修改
//			MarkupConfig markupConfig = new MarkupconfigWapper().selectbyPrimaryKey(agentUserId, rootUserId).get(0);
//			Logger.verifyEquals(markupConfig.getMarkupType(), 1, "验证markupType");
//			Logger.verifyEquals(markupConfig.getPercentage().intValue(), 33, "验证percentage");
//			Logger.verifyEquals(markupConfig.getDecimalType(), 2, "验证decimalType");
//			Logger.verifyEquals(markupConfig.getOnSaleType(), 1, "验证onSaleType");
//			Logger.verifyEquals(markupConfig.getRefreshProduct(), true, "验证refreshProduct");
//			Logger.verifyEquals(markupConfig.getConfigStatus(), 0, "验证configStatus");
//
//			// 验证加价规则
//			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId, "",
//					true);
//			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
//			Thread.sleep(5000);
//			List<ProductListDto> getProductLists = AddAgentProductCallService.GetProductLists(rootUserId);
//			List<ProductListDto> getProductLists1 = AddAgentProductCallService.GetProductLists(agentUserId);
//			ProductListDto agentProd = getProductLists1.get(0);
//			//代理价加价百分之三十三 =直销价 （保留一位小数）
//			String format = new DecimalFormat("#.0").format(agentProd.getCatalogList().get(0).getAgentPrice()*1.33);
//			Logger.verifyEquals(format,
//					""+agentProd.getCatalogList().get(0).getDirectPrice(), "");
//		} catch (Exception e) {
//			Logger.fail(e);
//		}
//	}
//
//	@Test
//	@Category({ P1.class })
//	@TestCase
//	public void Tc_SetMarkupConfig_004() {
//		Logger.start(true, "按比例加价百分之33，精确到后两位，而且自动上架到我的店铺");
//		try {
//			int rootUserId = 501475646;
//			int agentUserId = 501475647;
//			// 验证配置未修改
//			MarkupConfig markupConfig = new MarkupconfigWapper().selectbyPrimaryKey(agentUserId, rootUserId).get(0);
//			Logger.verifyEquals(markupConfig.getMarkupType(), 1, "验证markupType");
//			Logger.verifyEquals(markupConfig.getPercentage().intValue(), 33, "验证percentage");
//			Logger.verifyEquals(markupConfig.getDecimalType(), 3, "验证decimalType");
//			Logger.verifyEquals(markupConfig.getOnSaleType(), 1, "验证onSaleType");
//			Logger.verifyEquals(markupConfig.getRefreshProduct(), true, "验证refreshProduct");
//			Logger.verifyEquals(markupConfig.getConfigStatus(), 0, "验证configStatus");
//
//			// 验证加价规则
//			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId, "",
//					true);
//			addAgentProductBean.getCatalogList().get(0).getAgentPriceList().get(0).setAgentPrice(123.12);
//			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
//			Thread.sleep(5000);
//			List<ProductListDto> getProductLists = AddAgentProductCallService.GetProductLists(rootUserId);
//			List<ProductListDto> getProductLists1 = AddAgentProductCallService.GetProductLists(agentUserId);
//			ProductListDto agentProd = getProductLists1.get(0);
//			//代理价加价百分之三十三 =直销价 （保留两位小数）
//			String format = new DecimalFormat("#.00").format(agentProd.getCatalogList().get(0).getAgentPrice()*1.33);
//			Logger.verifyEquals(format,
//					""+agentProd.getCatalogList().get(0).getDirectPrice(), "");
//		} catch (Exception e) {
//			Logger.fail(e);
//		}
//	}
//
//	@Test
//	@Category({ P1.class })
//	@TestCase
//	public void Tc_SetMarkupConfig_005() {
//		Logger.start(true, "按比例加价百分之33，精确到十位数，而且自动上架到我的店铺");
//		try {
//			// 创建渠道商
//			CreateCodeBean createAllMsgSellerMch = GodmchManageCallService.CreateAllMsgSellerMch();
//			// 创建渠道商邀请码
//			CreateCodeCall createCodeCall2 = GodmchManageCallService.createCodeCall(createAllMsgSellerMch);
//			// 创建代理商
//			Integer agentUserId = GodmchManageCallService.CreateSellerMch(
//					createCodeCall2.getJsonObject().getAsJsonObject("result").get("code").getAsString());
//			int rootUserId = createAllMsgSellerMch.getMchId();
//
//			SetMarkupConfigBean bean = GodmchManageCallService.initSetMarketupBean(agentUserId,
//					Arrays.asList(rootUserId));
//			bean.setDecimalType(4);
//			SetMarkupConfigCall call = GodmchManageCallService.SetMarketupBeanCall(bean);
//			System.out.println(call.getJsonObject());
//			// 验证配置未修改
//			MarkupConfig markupConfig = new MarkupconfigWapper().selectbyPrimaryKey(agentUserId, rootUserId).get(0);
//			Logger.verifyEquals(markupConfig.getMarkupType(), 1, "验证markupType");
//			Logger.verifyEquals(markupConfig.getPercentage().intValue(), 33, "验证percentage");
//			Logger.verifyEquals(markupConfig.getDecimalType(), 4, "验证decimalType");
//			Logger.verifyEquals(markupConfig.getOnSaleType(), 1, "验证onSaleType");
//			Logger.verifyEquals(markupConfig.getRefreshProduct(), true, "验证refreshProduct");
//			Logger.verifyEquals(markupConfig.getConfigStatus(), 0, "验证configStatus");
//
//			// 验证加价规则
//			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId, "",
//					true);
//			addAgentProductBean.getCatalogList().get(0).getAgentPriceList().get(0).setAgentPrice(123.12);
//			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
//			Thread.sleep(5000);
//			List<ProductListDto> getProductLists = AddAgentProductCallService.GetProductLists(rootUserId);
//			List<ProductListDto> getProductLists1 = AddAgentProductCallService.GetProductLists(agentUserId);
//			ProductListDto agentProd = getProductLists1.get(0);
//			//代理价加价百分之三十三 =直销价 （保留两位小数）
//			String format = new DecimalFormat("#.0").format(agentProd.getCatalogList().get(0).getAgentPrice()*1.33/100);
//			Logger.verifyEquals((int) (new Double(format)*100)+"",
//					""+(int) agentProd.getCatalogList().get(0).getDirectPrice(), "");
//		} catch (Exception e) {
//			Logger.fail(e);
//		}
//	}
//	
//	
//	@Test
//	@Category({ P1.class })
//	@TestCase
//	public void Tc_SetMarkupConfig_0051() {
//		Logger.start(true, "按比例加价百分之33，精确到十位数时直销价小于成本价自动加10，而且自动上架到我的店铺");
//		try {
//			// 创建渠道商
//			CreateCodeBean createAllMsgSellerMch = GodmchManageCallService.CreateAllMsgSellerMch();
//			// 创建渠道商邀请码
//			CreateCodeCall createCodeCall2 = GodmchManageCallService.createCodeCall(createAllMsgSellerMch);
//			// 创建代理商
//			Integer agentUserId = GodmchManageCallService.CreateSellerMch(
//					createCodeCall2.getJsonObject().getAsJsonObject("result").get("code").getAsString());
//			int rootUserId = createAllMsgSellerMch.getMchId();
//
//			SetMarkupConfigBean bean = GodmchManageCallService.initSetMarketupBean(agentUserId,
//					Arrays.asList(rootUserId));
//			bean.setDecimalType(4);
//			SetMarkupConfigCall call = GodmchManageCallService.SetMarketupBeanCall(bean);
//			// 验证配置未修改
//			MarkupConfig markupConfig = new MarkupconfigWapper().selectbyPrimaryKey(agentUserId, rootUserId).get(0);
//			Logger.verifyEquals(markupConfig.getMarkupType(), 1, "验证markupType");
//			Logger.verifyEquals(markupConfig.getPercentage().intValue(), 33, "验证percentage");
//			Logger.verifyEquals(markupConfig.getDecimalType(), 4, "验证decimalType");
//			Logger.verifyEquals(markupConfig.getOnSaleType(), 1, "验证onSaleType");
//			Logger.verifyEquals(markupConfig.getRefreshProduct(), true, "验证refreshProduct");
//			Logger.verifyEquals(markupConfig.getConfigStatus(), 0, "验证configStatus");
//
//			// 验证加价规则
//			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId, "",
//					true);
//			addAgentProductBean.getCatalogList().get(0).getAgentPriceList().get(0).setAgentPrice(2);
//			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
//			Thread.sleep(5000);
//			List<ProductListDto> getProductLists = AddAgentProductCallService.GetProductLists(rootUserId);
//			List<ProductListDto> getProductLists1 = AddAgentProductCallService.GetProductLists(agentUserId);
//			ProductListDto agentProd = getProductLists1.get(0);
//			//2*1.33=2.66  四舍五入到十位数应该是0  但是吃亏了  所以售价提升到10
//			String format = new DecimalFormat("#.0").format(agentProd.getCatalogList().get(0).getAgentPrice()*1.33/100);
//			Logger.verifyEquals(10+(int) (new Double(format)*100)+"",
//					""+(int) agentProd.getCatalogList().get(0).getDirectPrice(), "");
//		} catch (Exception e) {
//			Logger.fail(e);
//		}
//	}

}